package com.lsh.payment.core.strategy.query;

import com.lsh.payment.core.strategy.vo.base.BasePayResponse;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Project Name: lsh-payment
 *
 * @author peter
 * @date 16/11/6
 * 北京链商电子商务有限公司
 * Package
 * desc:
 */
@Component
public class QueryStrategyContext {

    @Autowired
    private QueryStrategyFactory queryStrategyFactory;

    private static Logger logger = org.slf4j.LoggerFactory.getLogger(QueryStrategyContext.class);

    private QueryStrategy queryStrategy;

    /**
     * 调用对应支付平台组装支付请求报文
     *
     * @param payType 类型
     * @param params 参数
     * @return
     */
    public BasePayResponse queryPayStatusByParams(int payType, Map<String, Object> params) {

        queryStrategy = queryStrategyFactory.creator(payType);
        logger.info("支付查询策略类型" + queryStrategy.getStrategyNo());
        return queryStrategy.queryPayStatusByParams(params);
    }

}
